var $ = require('../../utils/Ajax.js');

Page({
  data: {
    items: [
      { name: '男', value: '1', checked: 'true' },
      { name: '女', value: '0' },
    ],
    UserName:"",
    Sex: 1,
    Mobile:"",
    Introduction:"",
    Theme:""
  },
  onLoad: function () {
    wx.setNavigationBarTitle({
      title: "填写信息"
    }),
    wx.setNavigationBarColor({
      frontColor: '#000000',
      backgroundColor: '#FDD436'
    })
  },
  UserName: function(e){
    this.data.UserName = e.detail.value;
  },
  Mobile: function (e) {
    this.data.Mobile = e.detail.value;
  },
  Introduction: function (e) {
    this.data.Introduction = e.detail.value;
  },
  Theme: function (e) {
    this.data.Theme = e.detail.value;
  },
  radioChange: function (e) {
    this.data.Sex = e.detail.value;
  },
  UnderReview: function(){
    if (this.data.UserName != '' && this.data.Mobile != '' && this.data.Introduction != '' && this.data.Theme != '' ){
      $.Ajax("api/x_to_leadway", "POST", {
        user_name: this.data.UserName,
        sex: this.data.Sex,
        mobile: this.data.Mobile,
        introduction: this.data.Introduction,
        theme: this.data.Theme
      }, function (res) {
        console.log(res)
        if (res.s) {
          wx.navigateTo({
            url: '../UnderReview/UnderReview',
          })
          $.Ajax("api/x_user", "POST", {}, function (res) {
            wx.setStorageSync('UserInfor', res.d);
          })
        } else {
          wx.showToast({
            title: res.m,
            icon: 'none',
            duration: 2000
          })
        }
      });
    }else{
      wx.showToast({
        title: "必填信息不能为空！",
        icon: 'none',
        duration: 2000
      })
    }
  }
})